﻿using System.Text;

namespace 测试
{
    internal class Program
    {
        static void Main(string[] args)
        {
           

        }

        public int TotalFruit(int[] fruits)
        {
            int ans = 0;
            Dictionary<int,int> x= new Dictionary<int,int>();
   
            int l = 0;

            for (int r = 0;r<fruits.Length;r++)
            {
                if (!x.ContainsKey(fruits[r]))
                x.Add(fruits[r], 1);

                else x[fruits[r]]++;

                
                while (x.Count > 2)
                {
                    int o= fruits[l];
                    x[o]--;
                    if (x[o] == 0)
                    {
                        x.Remove(o);
                    }
                    l++;
                }    

                ans=Math.Max(ans, );
            }
            return ans;
        }







    } 

   
        

        

       
        
        
    

    
    
}
